import { transformEmtyValue, toFix } from "@/utils/eam";

export function transform(value, fn) {
  const v = transformEmtyValue(value, "-");
  if (v == "-") {
    return v;
  }
  if (fn && typeof fn == "function") {
    return fn(v);
  }
  return toFix(v, 2);
}

// 查找series数据中，最后一个有值的对象
export function getLastSerieData(seriesData) {
  let obj = null;
  const len = seriesData.length - 1;
  for (let i = len; i >= 0; i--) {
    const ele = seriesData[i];
    if (![undefined, null, "-"].includes(ele.value)) {
      obj = { ...ele };
      break;
    }
  }
  return obj;
}
